package xinyu.customer.widget.dialog;

import android.view.View;

public abstract class OnNoDoubleClickListener implements View.OnClickListener {
    private int mThrottleFirstTime = 600;
    private long mLastClickTime = 0;

    public OnNoDoubleClickListener() {
    }

    public OnNoDoubleClickListener(int throttleFirstTime) {
        mThrottleFirstTime = throttleFirstTime;
    }

    @Override
    public void onClick(View view) {
        long currentTime = System.currentTimeMillis();
        if (currentTime - mLastClickTime > mThrottleFirstTime) {
            mLastClickTime = currentTime;
            onNoDoubleClick(view);
        }
    }

    /**
     * 不允许双击
     *
     * @param view View
     */
    public abstract void onNoDoubleClick(View view);
}
